<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<div class="pro_add">
    <p>编辑项目经历</p>
        <table>
            <tr>
                <td>
                    <div class="layui-inline">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-inline">
                            <input type="text" id="name" class="layui-input" placeholder="请填写项目名称"
                                   value="${project.name}" style="width: 490px">
                        </div>
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">项目时间</label>
                            <div class="layui-inline" id="test-range">
                                <div class="layui-input-inline">
                                    <input type="text" id="startTime" class="layui-input" placeholder="开始时间"
                                           value="<fmt:formatDate value="${project.startTime}" pattern="yyyy-MM-dd"/>"
                                           style="width: 213.4px">
                                </div>
                                <div class="layui-form-mid">-</div>
                                <div class="layui-input-inline">
                                    <input type="text" id="endTime" class="layui-input" placeholder="结束时间"
                                           value="<fmt:formatDate value="${project.endTime}" pattern="yyyy-MM-dd"/>"
                                           style="width: 213.4px">
                                </div>
                            </div>
                        </div>
                    </div>

                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div class="layui-inline">
                        <label class="layui-form-label"> 项目链接 </label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="link" placeholder="请填写项目链接" value="${project.link}"
                                   style="width: 490px">
                        </div>
                    </div>
                </td>

            <tr>
            <tr>
                <td colspan="2">
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">项目描述</label>
                        <div class="layui-input-block">
                            <textarea name="desc" id="description" placeholder="请填写项目描述（不超过500字）"
                                      class="layui-textarea">${project.description}</textarea>
                        </div>
                    </div>
                </td>

            </tr>
        </table>

    <button class="button_save" value="${project.id}" onclick="button_project_save(this.value)">保存并更新</button>
    <button class="button_cancel" id="button_project_cancel">取消</button>
</div>
<script>
    // $("#button_project_save").click(function () {
    function button_project_save(obj){
        let resumeId = $("#resumeId").val();
        // console.log($("#pro_info"))
        let projectId = obj;
        let name = $("#name").val();
        let startTime = $("#startTime").val();
        let endTime = $("#endTime").val();
        let link = $("#link").val();
        let description = $("#description").val();
        let param = "id=" + projectId + "&name=" + name + "&startTime=" + startTime
            + "&endTime=" + endTime + "&link=" + link + "&description=" + description;
        console.log(param);
        $.post('/hire/resume/project/update', param, function (res) {
            if (res.code == '200') {
                $("#pro_info").load("/hire/resume/project_info", {id: resumeId});
                $("#pro_edit").hide();
                $("#pro_info").show();
            } else {
                layer.msg(res.msg);
            }
        })
    }
    // })
    $("#button_project_cancel").click(function () {
        let resumeId = $("#resumeId").val();
        // console.log($("#pro_info"))
        $("#pro_info").load("/hire/resume/project_info", {id: resumeId});
        $("#pro_edit").hide();
        $("#pro_info").show();
    })
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#startTime' //指定元素

        });
    });
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#endTime' //指定元素

        });
    });
</script>